import java.io.IOException;

public class Server {

	private int chatPort;
	private int filePort;
	
	public Server(int chatPort, int filePort) throws IOException {
		this.chatPort = chatPort;
		this.filePort = filePort;
	}
	
	public void run() {
		
		new Thread(new FileListenThread(filePort)).start();
		
		Thread chatThread = new Thread(new ChatListenThread(chatPort));
		chatThread.start();
		
		try {
			// wait for thread to complete so program doesn't exit immediately
			chatThread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	 public static void main(String args[]) throws Exception {
		int chatPort = Integer.parseInt(args[0]);
		int filePort = Integer.parseInt(args[1]);
		new Server(chatPort, filePort).run();  // if you don't call run, it is just created
	}
}
